﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using FlickrSample.SL.Infrastructure.Repo.Download;
using FlickrSample.SL.Infrastructure.Repo.Flickr;
using FlickrSample.SL.Infrastructure.Repo.Photo;
using FlickrSample.SL.Infrastructure.Repo.Search;
using FlickrSample.SL.Infrastructure.Repo.User;
using XamlingCore.Infrastructure.ServiceLocation;

namespace FlickrSample.SL.Infrastructure
{
    public class ServiceLocator : ServiceLocatorBase
    {
        public static IWebDownloader WebDownloader { get; set; }

        private static IFlickrRepo flickrRepo;

        private static ISearchRepo searchRepo;

        private static IUserRepo userRepo;

        private static IPhotoRepo photoRepo;

        static ServiceLocator()
        {
            WebDownloader = new Repo.Download.Online.WebDownloader();
        }

        public static IFlickrRepo FlickrRepo
        {
            get
            {
                if (flickrRepo == null)
                {
                    flickrRepo = new Repo.Flickr.Online.FlickrRepo(WebDownloader);
                }
                return flickrRepo;
            }
            set { flickrRepo = value; }
        }

        public static ISearchRepo SearchRepo
        {
            get
            {
                if (searchRepo == null)
                {
                    searchRepo = new Repo.Search.Online.SearchRepo();
                }

                return searchRepo;
            }
            set { searchRepo = value; }
        }

        public static IUserRepo UserRepo
        {
            get
            {
                if (userRepo == null)
                {
                    userRepo = new Repo.User.Online.UserRepo();
                }

                return userRepo;
            }
            set { userRepo = value; }
        }

        public static IPhotoRepo PhotoRepo
        {
            get
            {
                if (photoRepo == null)
                {
                    photoRepo = new Repo.Photo.Online.PhotoRepo();
                }

                return photoRepo;
            }
            set { photoRepo = value; }
        }
    }
}
